package com.captain.lc.动态规划;

/**
 * Des:
 *
 * @author XL
 * @Date 2021/11/1 14:34
 */
public class Change518 {

    public int change(int amount, int[] coins) {
        if (coins == null || coins.length == 0) return 0;
        int[] dp = new int[amount + 1];
        //初始化数据
        dp[0] = 1;
        for (int coin : coins) {
            for (int i = coin; i <= amount; i++) {
                dp[i] = dp[i] + dp[i - coin];
            }
        }
        return dp[amount];
    }

    public static void main(String[] args) {
        System.out.println(new Change518().change(5, new int[]{1, 2, 5}));
    }

}
